﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CashShop.Bussiness;

namespace CashShop
{
    public partial class Form1 : Form
        
    {
        private CashFacade cf = new CashFacade();

        private decimal totalPrice = 0.00M;
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            //读取xml文件  绑定下拉菜单
            cbx.DataSource = cf.GetCashAcceptTypeList();
            cbx.SelectedIndex = 0;
        }

        private void btConfirm_Click(object sender, EventArgs e)
        {
            var total = 0.00M;
            //传值下拉活动的原价，计算实际收费
            total = cf.GetTotalPrice(cbx.SelectedItem.ToString(),
                Convert.ToDecimal(Price.Text) * Convert.ToDecimal(Num.Text));

            totalPrice += total;
            lbList.Items.Add("单价：" + Price.Text + "  数量：" + Num.Text + "  " + cbx.SelectedItem + "  合计：" +
                             total.ToString("C"));

            lbList.Text = totalPrice.ToString("C");
        }

        private void btReset_Click(object sender, EventArgs e)
        {
            //清空文本框s
            totalPrice = 0.00M;
            Num.Text = "";
            Price.Text = "";
            lbList.Items.Clear();
            labReturn.Text = "";
        }
    }
}
